package com.huluobo.a2203monthdemo.news

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/8/9.
 */
@HiltViewModel
class NewsViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getNewsSuccess by lazy { MutableLiveData<String>() }

    fun getAllNews(body: RequestBody) {
        executeNetRequest(
            { apiService.getAllNews(body) },
            getNewsSuccess::postValue
        )
    }

    val addNewsSuccess by lazy { MutableLiveData<String>() }
    fun addNews(body: RequestBody) {
        executeNetRequest(
            { apiService.addNews(body) },
            addNewsSuccess::postValue
        )
    }
}